package helper

import (
	"log"
	"os"
	"strings"
	"time"
)

/*
日志记录，按日期生成新的日志文件
@prefix 日志前缀
@...writeStr 记录的内容
*/
func WriteLog(prefix string, writeStr ...string){
	file,_ := os.OpenFile("./logs/" + time.Now().Format("2006-01-02") + "-logs.myt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
	logFile := log.New(file, prefix, log.Ltime|log.Ldate)

	sb := strings.Builder{}
	for _,v := range writeStr{
		sb.WriteString(v + " ")
	}

	logFile.Println(sb.String())
	file.Close()
}
